#pragma once
#include "DrawElement.h"
#include "DrawWindow.h"
#include <vector>
using namespace std;

class MillingMachine3C:public DrawElement
{
private:
	UINT m_nVBOVertices;
	UINT m_nColoursBufferID;
	UINT m_nIndicesBufferID;
	UINT m_nNormalBurrerID;
	UINT indicesNo;
	int levels;
	double * errorTable;
	float * normals;
	float * colours;
	double * buffer;
	DrawWindow * drawWindow;
	void adjustCongestionWindow(DrawWindow *& windows,int congestionWindowId,const Point3D & p);
	void fillDrawWindows(int count);
	void fillMachine(MY_DATATYPE *& material,UINT size);
	int getVerticesCount();
	//bool loadGLFunctions();
	void createMaterial();
	void createIndices();
	void createColours();
	void createNormalVectors();
	void createErrorTable();
	void updateNormal(UINT index);
public:
	int initDepth;
	UINT width;
	UINT height;
	
	int toolRPM;
	int toolVelocity;
	bool toolRotatingClockwise;
	MY_DATATYPE GetValueAt(int x,int y);
	void BindBuffer();
	void SetValueAtWithoutFlushing(int x,int y,MY_DATATYPE value);
	void UnbindBuffer();
	void Draw();
	MillingMachine3C(UINT _width,UINT _height,int _depth);
	~MillingMachine3C(void);
};

